import { UserRole,RolePermissions } from "../consts/role";

// 角色验证函数
export const isValidRole = (role: string): role is UserRole => {
  return Object.values(UserRole).includes(role as UserRole);
};

// 检查角色权限
export const hasPermission = (userRole: UserRole, permission: string): boolean => {
  return RolePermissions[userRole].includes(permission as any);
};

// 获取所有可用角色
export const getAllRoles = (): UserRole[] => {
  return Object.values(UserRole);
};